<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<f:loadBundle basename="demo.bundle.Messages" var="msg" />

<html>
<head>
<title>Semantic CBR Code Search</title>
<style type="text/css">
.odd-row {
    background-color: #ECF3FE;
}
.even-row {
    background-color: #FCFFFE;
}
.active-row {
    background-color: #FFEBDA;
}

.cur{
    cursor: pointer; 
}

.cell { 
	width: 200px;
	vertical-align:top;
}

.rsTitle { 
	padding: 5px;

	font-weight: bold;
	font-variant: small-caps;

	background-color: #E0ECF8;
	background-repeat: repeat-x;
	background-position: center;
}

.rsPanel {
	top: auto;
}

.rsLabel {
	font-size: 12px;
}

.rsInput {
	size: 220px;
	border-style: solid;
	border-width: 1px;
}

.rsButton {
	border-width: 2px;
}

.rsMessage {
	color: red;
	text-align: center;
}

</style>
</head>
<body>
<f:subview id="codeSearchList">
	<a4j:form>
		<rich:panel>
			<rich:dataTable	id="resultGrid"	
				value="#{codeSearchBean.casosUi}" var="caso"
				rows="25" binding="#{codeSearchBean.casosUiTable}"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" width="100%" border="0" rowClasses="cur" >

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{msg.csList_tgPanel_class_label}" />
					</f:facet>
					<h:outputText rendered="#{caso.classVisibilityRender} " value="#{caso.classVisibility} " />
					<h:outputText rendered="#{caso.classIsFinalRender} " value="#{caso.strFinal} " />
					<h:outputText rendered="#{caso.classIsStrictfpRender} " value="#{caso.strStrictfp} " />
					<h:outputText rendered="#{caso.classIsAbstractRender} " value="#{caso.strAbstract} " />
					<h:outputText value="#{caso.classType} " />
					<h:outputText rendered="#{caso.classPackageRender}" value="#{caso.classPackage} " />
					<h:outputText value="#{caso.className} " />
					<h:outputText rendered="#{caso.classExtendRender}" value="extend #{caso.classExtend} " />
					<h:outputText rendered="#{caso.classImplementsRender}" value="implements #{caso.classImplements}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{msg.csList_tgPanel_method_label}" />
					</f:facet>
					<h:outputText rendered="#{caso.methodVisibilityRender}" value="#{caso.methodVisibility} " />
					<h:outputText rendered="#{caso.methodIsAbstractRender}" value="#{caso.strAbstract} " />
					<h:outputText rendered="#{caso.methodIsAbstractRender}" value="#{caso.strFinal} " />
					<h:outputText rendered="#{caso.methodIsStrictfpRender}" value="#{caso.strStrictfp} " />
					<h:outputText rendered="#{caso.methodIsNativeRender}" value="#{caso.strNative} " />
					<h:outputText rendered="#{caso.methodIsStaticRender}" value="#{caso.strStatic} " />
					<h:outputText rendered="#{caso.methodIsSynchronizedRender}" value="#{caso.strSynchronized} " />
					<h:outputText value="#{caso.methodReturn} " />
					<h:outputText value="#{caso.methodName} " />
					<h:outputText value="(#{caso.methodParams}) " />
					<h:outputText rendered="#{caso.methodExceptionsRender}" value="throws #{caso.methodExceptions}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{msg.csList_hdColumn_similarity}" />
					</f:facet>
					<h:outputText value="#{caso.similarity}" />
				</rich:column>

                <rich:column width="20px">
	                <a4j:commandLink ajaxSingle="true" id="editlink"
	                	value="#{msg.csList_button_select}"
	                    oncomplete="#{rich:component('viewPanel')}.show()"
	                    actionListener="#{codeSearchBean.listenerRowSelected}" />
				</rich:column>

				<a4j:support id="rowSelect" event="onRowDblClick"
					oncomplete="#{rich:component('viewPanel')}.show()"
					actionListener="#{codeSearchBean.listenerRowSelected}" />   

				<rich:datascroller id="pagination-scroller" for="resultGrid" maxPages="10">
					<f:facet name="first">
						<h:outputText value="First" />
					</f:facet>
					<f:facet name="last">
						<h:outputText value="Last" />
					</f:facet>
				</rich:datascroller>
			</rich:dataTable>
			<br/>
			<br/>
			<rich:messages style="text-align: center;" infoClass="green" errorClass="red" />
			<!-- Contenedores -->
			<a4j:commandButton id="botonVolver" styleClass="rsButton" value="#{msg.csList_button_search}" action="#{codeSearchBean.clean}" type="reset" reRender="tabPanelBusqueda" />
		</rich:panel>
	</a4j:form>

	<rich:modalPanel id="viewPanel" autosized="true">
		<f:facet name="header">
			<h:outputText value="#{msg.csm_tabView_label}" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage id="hidelink" styleClass="hidelink" value="/images/close.png" />
				<rich:componentControl for="viewPanel" attachTo="hidelink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:panelGrid>
           <a4j:outputPanel ajaxRendered="true">
               <h:panelGrid>
				<h:inputTextarea id="codigoFuente" readonly="true"
					value="#{codeSearchBean.selectedSource}"
					style="width : 1125px; height : 600px;" />
               </h:panelGrid>
           </a4j:outputPanel>
		<a4j:form>
		<h:panelGrid style="text-align: center;" columns="2" columnClasses="cell, cell" width="50%">
			<h:panelGroup>
				<h:outputLabel styleClass="rsLabel" value="#{msg.csList_label_calificationId}" for="calificationId" />
				<h:selectOneMenu styleClass="rsInput" id="calificationId" value="#{codeSearchBean.targetCase.calificationId}">
					<f:selectItems value="#{codeSearchBean.calificationList}"/>
				</h:selectOneMenu>
	            <a4j:commandButton value="#{msg.csList_button_calificate}" styleClass="rsButton"
	            	actionListener="#{codeSearchBean.listenerCalificate}"
					oncomplete="#{rich:component('viewPanel')}.hide();" />
				</h:panelGroup>
            <a4j:commandButton value="#{msg.csList_button_back}" styleClass="rsButton"
                actionListener="#{codeSearchBean.listenerCalificateAsSeen}"
                oncomplete="#{rich:component('viewPanel')}.hide();" />
		</h:panelGrid>
		</a4j:form>
		</h:panelGrid>  
   </rich:modalPanel>
</f:subview>
</body>
</html>